#初版
src  = "A10;S20;W10;D30;X;A1A;B10A11;;A10;"
class Point:
    def __init__(self,x=0,y=0):
        self.__x =x
        self.__y =y
    def do(self,to,step=0):
        if to=='A':
            self.__x -= step
        elif to=='S':
            self.__y-=step
        elif to=='D':
            self.__x+=step
        else:
            self.__y+=step
        return self
    def __repr__(self):
        return'<Point : ({},{})>'.format(self.__x,self.__y)
    __str__ = __repr__
    def domain(self,src:str):
        src = src.split(';')
        for i in src :
            if len(i)==(1|2|3) and i[0] in set('ASDW'):
                try:
                    if i[1] == '-':
                        raise ValueError
                    temp = int(i[1:])
                except:
                    continue
                else:
                    self.do(i[0],temp)
        return self

print(Point().domain(src))

class XY:

    def __init__(self,x:int=0,y:int=0):
        self.__x = x
        self.__y = y
        setattr(__class__,"operation", {
        "A": self.A,
        "S": self.S,
        "W": self.W,
        "D": self.D
        })
    def __repr__(self):
        return'<Point : ({},{})>'.format(self.__x,self.__y)
    def A(self,step:int=0):
        self.__x -=step
        return self
    def S(self,step:int=0):
        self.__y -=step
        return self
    def W(self,step:int=0):
        return self.S(-step)
    def D(self,step:int=0):
        return self.A(-step)

    def domain(self,src,separator = ';'):
        for src in src.split(separator):
            try:
                if len(src)==(1|2|3) :
                    self.__class__.operation.get(src[0],lambda x:x)(int(src[1:]))
                else:
                    if src:
                        print("{}\n\t该坐标出错".format(src))
            # except TypeError as e:
            #     print("{}该坐标出错".format(src))
            #     continue
            except ValueError as e :
                print("{}\n\t该坐标出错".format(src))
                continue

        return self

print(XY().domain(src))


